interface DrawApi {
    drawCircle(): void;
}

class RedCircle implements DrawApi {
    drawCircle(): void {
        console.log("打印一个红色的圆");
    }
}

class GreenCircle implements DrawApi {
    drawCircle(): void {
        console.log("打印一个绿色的圆");
    }
}


abstract class Shape {
    drawApi: DrawApi;
    constructor(drawApi: DrawApi) {
        this.drawApi = drawApi;
    }
    abstract draw(): void;
}

// 创建一个实现了Shape抽象类的实体类
class Circle extends Shape {
    constructor(drawApi: DrawApi) {
        super(drawApi);
    }
    draw(): void {
        this.drawApi.drawCircle();
    }
}
// 步骤5 使用Shape 和DrawApi类画不同颜色的圆
let redCircle = new Circle(new RedCircle());
redCircle.draw();

let greenCircle = new Circle(new GreenCircle());
greenCircle.draw();